import 'package:flutter/material.dart';

import 'article.dart';
import 'types.dart';

class ListMainPage extends StatefulWidget {
  const ListMainPage({super.key});

  @override
  State<ListMainPage> createState() => _ListMainPageState();
}

class _ListMainPageState extends State<ListMainPage> {
  final List<TeachingFiles> items = teachingFiles;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Article List')),
      body: ListView.builder(
        itemCount: items.length,
        itemBuilder: (context, index) {
          var pos = (index + 1).toString().padLeft(2, '0');
          return ListTile(
            title: Text("$pos ${items[index].title}"),
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => ArticlePage(cls: items[index]),
                ),
              );
            },
          );
        },
      ),
    );
  }
}
